package com.ag.lwc.service;

import java.util.Date;
import java.util.List;

import com.ag.bean.TbLog;
import com.ag.bean.TbLogPlanStep;
import com.ag.bean.TbLogType;
import com.ag.bean.TbPsContent;
import com.ag.lwc.dao.MyTbLogPsContentDAO;
import com.ag.lwc.service.impl.LogService;

public class TbLogPsContentService {
	private MyTbLogPsContentDAO logPsContentDAO;
	public TbLogTypeService logTypeService;
	public LogService logService;
	//点击下一环节
	public void nextStep(String psId)
	{
		System.out.println("TbLogPsContentService:    下一环节的id: "+psId);
		TbLogType logType = logTypeService.findById("1002");
		List<TbPsContent> result = logPsContentDAO.findByPsId(psId);	//环节的内容
		TbLogPlanStep step = new TbLogPlanStep();
		step.setPsId(psId);														//日志所属的环节步骤
		if(result!=null)
		{
			for(TbPsContent content:result)					//遍历还击步骤的内容
			{
				TbLog tbLog = new TbLog();
				tbLog.setTbLogPlanStep(step);		//日志所在的步骤
				tbLog.setTbLogType(logType);   //日志类型为启动预案
				tbLog.setLogContent(content.getPscContent());	//日志类型为预案步骤的内容
				tbLog.setLogTime(new Date());
				System.out.println("新增步骤日志内容："+tbLog.getLogContent());
				logService.save(tbLog);		//保存日志
			}
		}
	}
	//查询预案步骤的内容列表
	public List<TbPsContent> findContents(String psId)
	{
		System.out.println("\nTbLogPsContentService: 预案步骤id："+psId);
		List<TbPsContent> result = logPsContentDAO.findByPsId(psId);
		return result;
		
	}
	//点击之前的环节就查询其环节的日志
	public List<TbLog> onceStep(String psId)
	{
		return null;
		
	}
	public MyTbLogPsContentDAO getLogPsContentDAO() {
		return logPsContentDAO;
	}
	public void setLogPsContentDAO(MyTbLogPsContentDAO logPsContentDAO) {
		this.logPsContentDAO = logPsContentDAO;
	}
	public TbLogTypeService getLogTypeService() {
		return logTypeService;
	}
	public void setLogTypeService(TbLogTypeService logTypeService) {
		this.logTypeService = logTypeService;
	}
	public LogService getLogService() {
		return logService;
	}
	public void setLogService(LogService logService) {
		this.logService = logService;
	}

}
